<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
<script>
    var obj = {
        id: 1,
        name: 'marry',
        age: 21,
        score: 100,
        grade: 'aaaaa'
    }

    for (var key in obj) {
        if (key != name) {
            obj[key] = null
        }
    }
    console.log(obj)

    var createTime = '2022-03-15 14:29:24'
    var myDate = createTime ? new Date(createTime) : new Date()
    var month = myDate.getMonth()
    const lastMonth = new Date(`${myDate.getFullYear()}-${month}-01`);
    console.log(lastMonth)


    const a = new Date(`${new Date().getFullYear()}-${new Date().getMonth() + 1}`);
    console.log(a)


    console.log((new Date().getFullYear() * 100 + (new Date().getMonth() + 1)).toString().slice(0, 4) + '-' + (new Date().getFullYear() * 100 + (new Date().getMonth() + 1)).toString().slice(4, 6))
</script>
</body>

</html>
